#!/usr/bin/env ruby

class Range
  # new method
  def join(sep_string=$,)
    unless [String, NilClass].detect { |cls| sep_string.is_a?(cls) }
      raise TypeError, 'arg must be String or nil', caller
    end
    
    return to_a.join(sep_string)
  end
end

########################################

=begin
#doctest Demo Range.join
>> (1..5).join
=> "12345"
>> (1..5).join(', ')
=> "1, 2, 3, 4, 5"
=end
